home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_tem_sharkdoor.cog < prev    next >
Text File  |  1999-11-15  |  11KB  |  401 lines

  1. # Jones 3D Cog Script
  2. #
  3. # TEM_SharkDoor.cog
  4. #
  5. # shark key = 85
  6. #
  7. # [TRM]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.  
  14.     message     startup
  15.     message     user0
  16.     message     activated
  17.     
  18.     # ** local things **
  19.     thing       player          local
  20.     thing       playerTarget    local
  21.     thing       indy            local
  22.     
  23.     # ** misc things **
  24.     thing       door            # shark door
  25.     thing       doorOffset      # offset for door
  26.     thing       keyOffset       # offset for keyhole
  27.     thing       insideOffset    # offset for inside of door
  28.     thing       look_Door       # interp secondary focus
  29.     thing       sharkKey        # put the key in the hole
  30.     thing       walkTarg1
  31.     
  32.     # ** sectors **
  33.     sector      doorSec
  34.     
  35.     # ** surfaces **
  36.     surface     doorway
  37.     surface     keyHole
  38.     
  39.     template    tpl_Indy=indy_sh_actor      local
  40.     template    tpl_Ghost=ghost                local
  41.     
  42.     # ** using the wrong or no item lines (whichLine = 1) **
  43.     sound        in_WrongLine0=Inxj089.wav       local # That didn't work-->in_sayline[11]
  44.     sound        in_WrongLine1=Inxj090.wav        local # ...something wrong.
  45.     sound        in_WrongLine2=Inxj092.wav        local # Hmm...didn't quite work.
  46.     sound        in_WrongLine3=Inxj060.wav        local # I don't think...right answer
  47.     sound        in_WrongLine4=Inxj087.wav        local # Whoops.
  48.     sound        in_WrongLine5=Inxj088.wav        local # Nope.
  49.     sound        in_WrongLine6=Inxj091.wav        local # Of course that didn't work.
  50.     
  51.     # ** locked door lines (whichLine = 2) **
  52.     sound        in_DoorLocked0=Inxj081.wav        local # Oh no...why...always locked?
  53.     sound       in_DoorLocked1=Inxj076.wav      local # This door is locked
  54.     sound       in_DoorLocked2=Inxj077.wav      local # it's locked
  55.     
  56.     # ** key hole lines (whichLine = 3) **
  57.     sound        in_keyHole0=Inxj077.wav            local # It's locked.
  58.     sound        in_keyHole1=Inxj078.wav            local # Locked.
  59.     sound        in_keyHole2=Inxj082.wav            local # keyhole here...just need key.
  60.     sound        in_keyHole3=Inxj080.wav            local # Locked...luck never changes.
  61.     
  62.     # ** success key lines (whichLine = 4) **
  63.     sound        in_Success0=Inxj110.wav            local # Success!-->in_sayline[0]
  64.     sound        in_Success1=Inxj108.wav            local # There!
  65.     sound        in_Success2=Inxj109.wav            local # It fits!
  66.     sound        in_Success3=Inxj103.wav            local # Whoa! It opened.
  67.     sound        in_Success4=Inxj111.wav            local # what...know...worked!
  68.     sound        in_Success5=Inxj106.wav            local # ...got lucky.
  69.     sound        in_Success6=Inxj105.wav            local # ...be damned...opened.
  70.     
  71.     # ** misc sounds **
  72.     sound       in_LockedAgain=Inxj079.wav                         local   # locked again.
  73.     sound       sfx_Unlock=tem_monkeykey_unlock_c.wav       local   # turning key sfx
  74.     
  75.     cog         cog_Hint
  76.     
  77.     # ** vectors **
  78.     vector      keyCamTarg      local
  79.     
  80.     # ** subroutines **
  81.     flex        unlock          local
  82.     flex        noWayOut        local
  83.     flex        speak           local
  84.     
  85.     # ** ints **
  86.     int         playing=0       local
  87.     int         inside=0        local
  88.     int         unlocked=0      local
  89.     int         newComment      local
  90.     int         oldComment      local
  91.     int         whichLine       local
  92.     int         curItem         local
  93.     
  94.     int         doorCam=0       local
  95.     int         keyCam=0        local
  96.         
  97. end
  98.  
  99. # ========================================================================================
  100. code
  101.  
  102. startup:
  103.  
  104.     # hide sharkKey
  105.     SetThingFlags(sharkKey, 0x80000);
  106.     
  107.     SetThingLight(door, '0.35 0.2 0.2', 0.001, 0.1);
  108.     SectorAdjoins(doorSec, 0);
  109.     return;
  110.       
  111. # ========================================================================================
  112.  
  113. user0:
  114.  
  115.     # close door when player approaches tiki
  116.     SetThingLight(door, '0.2 0.2 0.2', 0.001, 0.1);
  117.     ClearAdjoinFlags(doorway, 2);       # no move
  118.     MoveToFrame(door, 0, 2.0);
  119.     WaitForStop(door);
  120.     SetAdjoinFlags(doorway, 2);         # move
  121.     SectorAdjoins(doorSec, 0);
  122.     
  123.     inside = 1;
  124.     
  125.     return;
  126.  
  127. # ========================================================================================
  128.  
  129. activated:
  130.         
  131.     player = GetLocalPlayerThing();
  132.     curItem = GetCurItem(player);
  133.     
  134.     if((GetSenderRef() == door) && (unlocked == 0) && (playing == 0))
  135.     {
  136.         # player activated with an item
  137.         if(curItem > 0)
  138.         {
  139.             playing = 1;
  140.             # say wrong item lines
  141.             whichLine = 1;
  142.             doorCam = 1;
  143.             Call speak;
  144.             doorCam = 0;
  145.         }
  146.         
  147.         # normal activation
  148.         else
  149.         {
  150.             playing = 1;
  151.             # say door locked lines
  152.             whichLine = 2;
  153.             doorCam = 1;
  154.             Call speak;
  155.             doorCam = 0;
  156.         }
  157.     }
  158.     
  159.     else if((GetSenderRef() == keyHole) && (unlocked == 0) && (playing == 0))
  160.     {
  161.         # player is correctly using shark kay
  162.         if(curItem == 85)
  163.         {
  164.             unlocked = 1;
  165.             # unlock the door
  166.             Call unlock;
  167.         }
  168.  
  169.         else
  170.         {
  171.             playing = 1;
  172.             # say need key lines
  173.             whichLine = 3;
  174.             keyCam = 1;
  175.             Call speak;
  176.             keyCam = 0;
  177.         }
  178.     }
  179.     
  180.     # player can't get back out of room
  181.     else if((GetSenderRef() == door) && (inside == 1) && (playing == 0))
  182.     {
  183.         playing = 1;
  184.         Call noWayOut;
  185.     }
  186.         
  187.     return;
  188.  
  189. # ========================================================================================
  190.  
  191. unlock:
  192.  
  193.     # solve hint7
  194.     SendMessage(cog_Hint, user0);
  195.     
  196.     # do cutscene stuff
  197.     MakeMeStop();
  198.     StartCutscene(0);
  199.     
  200.     # offset camera to keyOffset
  201.     SetExtCamLookOffsetToThing(player);
  202.     SetExtCamOffsetToThing(keyOffset);
  203.     
  204.     # put away any weapon
  205.     DeselectWeaponWait(player);
  206.     
  207.     Sleep(0.5);
  208.     
  209.     # create target at player position
  210.     keyCamTarg = VectorAdd(VectorTransformToOrient(player, '0.0 0.0 0.0'), GetThingPos(player));
  211.     playerTarget = CreateThingAtPos(tpl_Ghost, GetThingSector(player), keyCamTarg, '0 0 0');
  212.     CaptureThing(playerTarget);
  213.         
  214.     # activate key hole
  215.     PlayMode(player, 60, 0);
  216.     Sleep(0.3);
  217.     
  218.     # show sharkKey and light it up
  219.     ClearThingFlags(sharkKey, 0x80000);
  220.     SetThingLight(sharkKey, '0.1 0.2 0.1', 0.001, 0.01);
  221.     
  222.     # slide it in
  223.     MoveToFrame(sharkKey, 1, 1.0);
  224.     
  225.     # play unlock sfx
  226.     PlaySoundLocal(sfx_Unlock, 1.0, 0.0, 0x0, 1);
  227.     
  228.     # remove key from inventory
  229.     ChangeInv(player, 85, -1);
  230.     
  231.     # switch to keyOffset camera
  232.     SetCameraFocus(2, keyOffset);
  233.     SetCameraSecondaryFocus(2, playerTarget);
  234.     SetCurrentCamera(2);
  235.     SetCameraFOV(90, 0, 0.0);
  236.     
  237.     # create indy actor
  238.     indy = CreateThing(tpl_Indy, player);
  239.     CaptureThing(indy);
  240.     
  241.     # outfit indy actor
  242.     CopyPlayerHolsters(player, indy);
  243.     
  244.     # hide player show indy
  245.     SetThingFlags(player, 0x80000);
  246.     ClearThingFlags(indy, 0x80000);
  247.     
  248.     # set camera interp speed turn on look interp
  249.     SetCameraInterpSpeed(2, 2.0);
  250.     SetCameraLookInterp(2, 1);
  251.     Sleep(0.01);
  252.     
  253.     # interp to look_Door
  254.     SetCameraSecondaryFocus(2, look_Door);
  255.     
  256.     # rest for a bit
  257.     Sleep(1.0);
  258.     
  259.     # clear door adjoin
  260.     SectorAdjoins(doorSec, 1);
  261.     
  262.     # open the door
  263.     MoveToFrame(door, 1, 1.0);
  264.     
  265.     # indy looks at look_Door
  266.     AISetLookThing(indy, look_Door);
  267.     
  268.     # say success line
  269.     Sleep(1.0);
  270.     PlayVoice(player, in_Success0[RandBetween(0, 6)], 1.0, 1);
  271.     
  272.     # walk indy closer to door
  273.     AISetMoveSpeed(indy, 1.0);
  274.     AISetLookThing(indy, walkTarg1);
  275.     AISetMoveThing(indy, walkTarg1, 1);
  276.         
  277.     # wait for door to open all the way
  278.     #WaitForStop(door);
  279.     Sleep(0.5);
  280.     
  281.     # indy looks back at sharkKey
  282.     #AISetLookThing(indy, sharkKey);
  283.     
  284.     # move camera focus back to player
  285.     #SetCameraInterpSpeed(2, 1.0);
  286.     #SetCameraSecondaryFocus(2, playerTarget);
  287.     
  288.     Sleep(1.0);
  289.  
  290.     # stop any unfinished animations
  291.     ResetThing(player);
  292.     
  293.     # Get the player into position
  294.     CopyOrientAndPos(indy, player);
  295.     
  296.     # hide actor show player
  297.     SetThingFlags(indy, 0x80000);
  298.     ClearThingFlags(player, 0x80000);
  299.     
  300.     # restore camera to player
  301.     SetCameraPosition(1, GetThingPos(keyOffset));
  302.     SetCurrentCamera(1);
  303.     RestoreExtCam();
  304.     
  305.     # turn off look interp
  306.     SetCameraLookInterp(2, 0);
  307.     
  308.     # restore controls
  309.     ClearActorFlags(player, 0x200000);
  310.     EndCutscene();
  311.     
  312.     playing = 0;
  313.     
  314.     return;
  315.     
  316. # ========================================================================================
  317.  
  318. noWayOut:
  319.  
  320.     # do cutscene stuff
  321.     MakeMeStop();
  322.     StartCutscene(0);
  323.     
  324.     # offset camera
  325.     SetExtCamOffsetToThing(insideOffset);
  326.     
  327.     # put away any weapon
  328.     DeselectWeaponWait(player);
  329.     
  330.     # nudge door
  331.     PlayMode(player, 60, 0);
  332.     Sleep(0.3);
  333.     
  334.     # say locked again line
  335.     PlayVoice(player, in_LockedAgain, 1.0, 1);
  336.     
  337.     # restore camera and controls
  338.     RestoreExtCam();
  339.     ClearActorFlags(player, 0x200000);
  340.     EndCutscene();
  341.     
  342.     playing = 0;
  343.     
  344.     return;
  345.     
  346. # ========================================================================================
  347.  
  348. speak:
  349.  
  350.     while (newComment == oldComment) 
  351.     {
  352.         newComment = RandBetween(0, 2);
  353.     }
  354.     
  355.     oldComment = newComment;
  356.     
  357.     # do cutscene stuff
  358.     MakeMeStop();
  359.     StartCutscene(0);
  360.     
  361.     # offset camera
  362.     if(doorCam == 1) SetExtCamOffsetToThing(doorOffset);
  363.     
  364.     else if(keyCam == 1) SetExtCamOffsetToThing(keyOffset);
  365.     
  366.     # put away any weapon
  367.     DeselectWeaponWait(player);
  368.     
  369.     # activate door
  370.     PlayMode(player, 60, 0);
  371.     Sleep(0.3);
  372.     
  373.     if(whichLine == 1)
  374.     {
  375.         PlayVoice(player, in_WrongLine0[RandBetween(0, 6)], 1.0, 1);
  376.     }
  377.     
  378.     else if(whichLine == 2)
  379.     {
  380.         PlayVoice(player, in_DoorLocked0[RandBetween(0, 2)], 1.0, 1);
  381.     }
  382.     
  383.     else if(whichLine == 3)
  384.     {
  385.         PlayVoice(player, in_keyHole0[RandBetween(0, 3)], 1.0, 1);
  386.     }
  387.     
  388.     # restore offsetCam and controls
  389.     RestoreExtCam();
  390.     ClearActorFlags(player, 0x200000);
  391.     EndCutscene();
  392.     
  393.     playing = 0;
  394.     
  395.     return;
  396.  
  397. # ========================================================================================
  398.  
  399. end
  400.  
  401.